<template>
	<div class="comment-page">
		<CommentList :comments="comments" @submit="loadComments" class="commoent-list" />
		<CommentForm @submit="loadComments" :move-id="moveId"/>
	</div>
</template>

<script>
	import CommentList from './CommentList'
	import CommentForm from './CommentForm'


	export default {
		components: {
			CommentList,
			CommentForm
		},
		props: {
			moveId: {
				type: String
			}
		},
		data() {
			return {
				comments: []
			}
		},
		mounted() {
			// 页面加载时加载评论列表
			this.loadComments()
		},
		methods: {
			loadComments() {
				console.log(this.moveId);
				this.$ajax.get('/film/post/list', {
					t: 1684075619622,
					page: '1',
					limit: '10',
					key: this.moveId
				}).then(res => {
					if (res.code === 0) {
						this.comments = res.page.list
					} else {
						this.$toast(res.msg)
					}

				})
			}
		}
	}
</script>

<style scoped>
	
	.comment-page {
		padding: 20px;
	}

	.comment-list .comment {
		margin-bottom: 10px;
	}

	.comment-form textarea {
		display: block;
		width: 100%;
		height: 100px;
		box-sizing: border-box;
		margin-bottom: 10px;
	}

	.comment-form button {
		float: right;
	}
</style>